//
//  FDMBroadcastPushFMCollectionViewCell.m
//  Entertainment
//
//  Created by dllo on 16/4/21.
//  Copyright © 2016年 付冬梅. All rights reserved.
//

#import "FDMBroadcastPushFMCollectionViewCell.h"
#import "FDMBroadcastRecommandRadioListModel.h"

@interface FDMBroadcastPushFMCollectionViewCell ()

@property (nonatomic, retain) FDMBaseLabel *titleLabel;
@property (nonatomic, retain) UIImageView *titleImage;

@end
@implementation FDMBroadcastPushFMCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.titleLabel = [[FDMBaseLabel alloc] init];
        [self.contentView addSubview:self.titleLabel];
        [self.titleLabel release];
        self.titleImage = [[UIImageView alloc] init];
        [self.contentView addSubview:self.titleImage];
        [self.titleImage release];
    }
    return self;
}

- (void)dealloc {
    [self.titleImage release];
    [self.titleLabel release];
    [super dealloc];
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super applyLayoutAttributes:layoutAttributes];
    self.contentView.backgroundColor = [UIColor whiteColor];
    self.titleImage.layer.borderWidth = 3;
    self.titleImage.layer.borderColor = [UIColor grayColor].CGColor;
    [self.titleImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top);
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-30);
        make.right.equalTo(self.contentView.mas_right).with.offset(0);
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_bottom).with.offset(-20);
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(0);
        make.right.equalTo(self.contentView.mas_right).with.offset(0);
    }];
    
}

- (void)setRecommandModel:(FDMBroadcastRecommandRadioListModel *)recommandModel {
    if (_recommandModel != recommandModel) {
        [_recommandModel release];
        _recommandModel = [recommandModel retain];
        self.titleLabel.text = _recommandModel.rname;
        [self.titleImage sd_setImageWithURL:[NSURL URLWithString:_recommandModel.picPath] placeholderImage:PLACEHOLDER_IMAGE];
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
